package com.ioi.servlet.book;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ioi.base.R;
import com.ioi.service.BookService;
import com.ioi.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 图书根据名称查询接口
 *
 * @author LILIBO
 * @since 2024/5/24
 */
@WebServlet("/api/book/check")
public class BookCheckServlet extends HttpServlet {

    // 引入业务逻辑层
    private final BookService bookService = new BookServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获得请求参数（已由全局过滤器统一处理参数到作用域）
        String jsonQ = (String) request.getAttribute("jsonQ");

        // 解析JSON格式的请求数据
        JSONObject json = JSONObject.parseObject(jsonQ);

        R result = R.failure();

        // 将响应结果设置到作用域（由全局过滤器统一处理响应结果）
        request.setAttribute("jsonR", JSON.toJSONString(result));
    }

}
